﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NaturalNote.Web.DbStorage;
using NaturalNote.Web.DbStorage.Models;

namespace NaturalNote.Web.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class NNPageController : ControllerBase
    {
        PageQueryService pageQueryService;

        public NNPageController(PageQueryService pageQueryService)
        {
            this.pageQueryService = pageQueryService;
        }

        [HttpGet(nameof(GetPage))]
        public async Task<PageViewModel> GetPage(long pageId)
        {
            var page = await pageQueryService.Get(pageId);
            return page;
        }

        [HttpGet(nameof(GetBlocks))]
        public async Task<List<PageBlockViewModel>> GetBlocks(long pageId)
        {
            var blocks = await pageQueryService.GetBlocks(pageId);
            return blocks;
        }
    }
}
